package com.example.wan1.view.system.knowledge;

import com.example.wan1.data.BaseObserver;
import com.example.wan1.data.RetrofitUtil;
import com.example.wan1.data.RxSchedulers;
import com.example.wan1.model.KnowledgeBean;

import java.util.List;

import javax.inject.Inject;

/***
 * 创建时间：2020/7/9 19:57
 * 创建人：10850
 * 功能描述：
 */
public class KnowledgePresenter
        implements KnowledgeContract.Presenter {

    @Inject
    KnowledgeContract.View mView;

    @Inject
    public KnowledgePresenter() {

    }

    @Override
    public void getKnowledgeTreeData() {
        RetrofitUtil.getInstance().getKnowledgeTree()
                .compose(RxSchedulers.observableIO2Main())
                .subscribe(new BaseObserver<List<KnowledgeBean>>() {
                    @Override
                    public void onSuccess(List<KnowledgeBean> result) {
                        mView.onSuccess(result);
                    }

                    @Override
                    public void onFailure(Throwable e, String errorMsg) {
                        mView.onFailure(e.getMessage());
                    }
                });
    }
}
